package com.tedu.egmybatis1.controller;

import com.tedu.egmybatis1.mapper.UserMapper;
import com.tedu.egmybatis1.pojo.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.Scanner;

@Controller
public class UserController {
    @Autowired
    private UserMapper mapper;

    public void a() {
        System.out.println("请选择功能：");
        System.out.println("1.添加产品");
        System.out.println("2.由编号查询产品");
        System.out.println("3.删除产品");
        System.out.println("4.查询所有产品");
        Scanner scanner = new Scanner(System.in);
        int count=scanner.nextInt();
        switch (count){
            case 1:
                useInsert();
                break;
                case 2:
                    //selectSingleProduct();
                    break;
                case 3:
                   // deleteById();
                    break;
                case 4:
                    //deleteById();
                    break;
        }

    }

    private int useInsert(){
        Scanner scanner = new Scanner(System.in);
        Product product = new Product();
        System.out.println("请输入产品编号：");
        product.setId(scanner.nextInt());
        System.out.println("请输入产品名称：");
        product.setTitle(scanner.next());
        System.out.println("请输入产品价格：");
        product.setPrice(scanner.nextInt());
        System.out.println("请输入产品库存：");
        product.setStock(scanner.nextInt());
        int result= mapper.insertProduct(product);
        return result;
    }

//    private Product selectSingleProduct(){
//        return null;
//    }
//
//    private int deleteById(){
//        return 0;
//    }
//
//    private List<Product> deleteById(){
//        return null;
//    }


}
